package org.crazyit.activiti_d2._5_SuspendProcessDef;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.ProcessDefinition;

public class SuspendProcessDef {

    public static void main(String[] args) {

        //1. 创建流程引擎
        ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();

        //2. 得到流程存储服务实例
        RepositoryService repositoryService = engine.getRepositoryService();

        /*//3. 部署流程描述文件
        Deployment dep = repositoryService.createDeployment().addClasspathResource("suspendProcessDef.bpmn").deploy();

        //4. 查询流程定义实体
        ProcessDefinition def = repositoryService.createProcessDefinitionQuery().deploymentId(dep.getId()).singleResult();

        //5. 调用suspendProcessDefinitionById 中止流程定义
        repositoryService.suspendProcessDefinitionById(def.getId());

        //6. 调用activateProcessDefinitionById 激活流程定义
        repositoryService.activateProcessDefinitionById(def.getId());

        //7. 调用suspendProcessDefinitionByKey 中止流程定义
        repositoryService.suspendProcessDefinitionByKey(def.getKey());

        //8. 调用activateProcessDefinitionByKey 激活流程定义
        repositoryService.activateProcessDefinitionByKey(def.getKey());*/

        repositoryService.activateProcessDefinitionById("vacationProcess:5:60003");

    }

}
